package com.ziyun.pop.modules.storeMaterials.dao;

import com.ziyun.pop.modules.storeMaterials.entity.StoreStockMaterialEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 门店库存明细表
 * 
 * @author guizhao
 * @email 296588519@qq.com
 * @date 2018-10-08 11:31:20
 */
public interface StoreStockMaterialDao extends BaseMapper<StoreStockMaterialEntity> {

    StoreStockMaterialEntity getStockMaterial(@Param("materialId") String materialId, @Param("sellerId")Long sellerId);

    Integer updateMaterialInfo(

            @Param("quantity")BigDecimal quantity
            ,@Param("money")BigDecimal money
            ,@Param("materialId")String materialId
            ,@Param("stockID")Integer stockID

            );

    Integer updateMaterialWarhouse(@Param("materialQuantity")BigDecimal materialQuantity,@Param("quantity")BigDecimal quantity
            ,@Param("materialId")String materialId
            ,@Param("stockId")Integer stockId
            ,@Param("direction")Integer directione
            ,@Param("updateTime")Date updateTime
           ,@Param("price")BigDecimal price


    );

    Integer updateMaterialWarhouse2(
            @Param("quantity")BigDecimal quantity
            ,@Param("date")Date date
            ,@Param("moneys")BigDecimal moneys
            ,@Param("materialId")String materialId
            ,@Param("stockId")Integer stockId
    );

    BigDecimal getMaterialQuantityByMaterialID(@Param("materialId")String materialId,@Param("stockId")Integer stockId);



    Integer updateQuantityByMaterialId(@Param("materialId")String materialId,
                                       @Param("quantity")BigDecimal quantity,
                                       @Param("price")BigDecimal price,
                                       @Param("stockId")Integer stockId
                                       );

    @Select("select * from store_stock_material where material_id = #{materialId}")
    List<StoreStockMaterialEntity> getCostByMaterialId(String materialId);


    @Select(" select material_quantity from store_stock_material where material_id = #{materialId} and stock_id = #{stockId} ")
    BigDecimal getMaterialQuantityByStockId(@Param("materialId") String materialId,@Param("stockId") Integer stockId);

    @Select(" select cost from store_stock_material where material_id = #{materialId} and stock_id = #{stockId} ")
    BigDecimal getCostByMaterialIdAndStockId(@Param("materialId") String materialId,@Param("stockId") Integer stockId);

    Integer updateTIStoreStock(@Param("materialQuantity") BigDecimal materialQuantity, @Param("stockId") Integer stockId, @Param("materialId") String materialId);
}
